package io.renren.modules.wap.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.commons.dynamic.datasource.annotation.DataSource;
import io.renren.modules.wap.dao.ExternalOrdersComplainDao;
import io.renren.modules.wap.dto.ExternalOrdersComplainDTO;
import io.renren.modules.wap.entity.ExternalOrdersComplainEntity;
import io.renren.modules.wap.service.ExternalOrdersComplainService;
import cn.hutool.core.util.StrUtil;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 对接三方订单投诉退订
 *
 * @author Liang Pei 
 * @since 1.0.0 2025-01-15
 */
@Service
@DataSource("wap")
public class ExternalOrdersComplainServiceImpl extends CrudServiceImpl<ExternalOrdersComplainDao, ExternalOrdersComplainEntity, ExternalOrdersComplainDTO> implements ExternalOrdersComplainService {

    @Override
    public QueryWrapper<ExternalOrdersComplainEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");

        QueryWrapper<ExternalOrdersComplainEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public ExternalOrdersComplainEntity getByOrderNo(String orderNo) {
        return baseDao.selectOne(new QueryWrapper<ExternalOrdersComplainEntity>().eq("order_no", orderNo));
    }
}